import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'
import { setupRouterGuards } from './guards'

const routes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    meta: { title: '仪表盘', icon: 'Odometer' },
    children: [
      {
        path: '/dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '仪表盘', icon: 'Odometer' }
      }
    ]
  },
  {
    path: '/media',
    component: Layout,
    redirect: '/media/list',
    meta: { title: '媒体管理', icon: 'HelpFilled' },
    children: [
      {
        path: '/media/list',
        name: 'MediaList',
        component: () => import('@/views/media/list.vue'),
        meta: { title: '媒体列表', icon: 'Grid' }
      },
      {
        path: '/media/space',
        name: 'MediaSpace',
        component: () => import('@/views/media/space.vue'),
        meta: { title: '广告位列表', icon: 'Notification' }
      }
    ]
  },
  {
    path: '/report',
    component: Layout,
    redirect: '/report/hour',
    meta: { title: '报表管理', icon: 'Menu' },
    children: [
      {
        path: '/report/hour',
        name: 'HourReport',
        component: () => import('@/views/report/hourReport.vue'),
        meta: { title: '时数据', icon: 'DataLine' }
      },
      {
        path: '/report/hourCompare',
        name: 'HourCompare',
        component: () => import('@/views/report/hourCompare.vue'),
        meta: { title: '时数据比对', icon: 'DataBoard' }
      },
      {
        path: '/report/day',
        name: 'DayReport',
        component: () => import('@/views/report/dayReport.vue'),
        meta: { title: '日数据', icon: 'DataAnalysis' }
      },
      {
        path: '/report/spaceDay',
        name: 'SpaceDayReport',
        component: () => import('@/views/report/spaceDayReport.vue'),
        meta: { title: '广告位日报', icon: 'DataAnalysis', hidden: true }
      },
      {
        path: '/report/spaceHour',
        name: 'SpaceHourReport',
        component: () => import('@/views/report/spaceHourReport.vue'),
        meta: { title: '广告位时报', icon: 'DataAnalysis', hidden: true }
      },
      {
        path: '/report/query',
        name: 'QsReport',
        component: () => import('@/views/report/qsReport.vue'),
        meta: { title: '清算报表', icon: 'Money' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

setupRouterGuards(router)

export default router